class Faction(object):
    def __init__(self,fz=0,fm=1):
        self.__fz = fz
        if fm == 0:
            raise ValueError('分母不能为0')
        else:
            self.__fm =fm
    @property
    def fz(self):
        return self.__fz
    @property
    def fm(self):
        return self.__fm
    # 将分子和分母转换成分数格式
    def chang_format(self):
        min_value = min(self.__fz,self.__fm)
        max_value = max(self.__fz,self.__fm)
        while max_value % min_value != 0:
            temp = max_value%min_value
            max_value = min_value
            min_value = temp
        self.__fz //= min_value
        self.__fm //= min_value
        if self.__fm == 1:
            str = "{fz}".format(fz=self.__fz)
        else:
            str ="{fz}/{fm}".format(fz=self.__fz, fm=self.__fm)
        return str
#  定义一个计算类，专门进行分数的加，减，乘，除
class ManageFaction(object):
    # 计算两个分数的和，差，积，商
    def adjust(self,fc1,fc2,sign="+"):
        sign = sign.strip(' ')
        if sign == '+':
            fz = fc1.fz * fc2.fm + fc1.fm * fc2.fz
        elif sign == "-":
            fz = fc1.fz * fc2.fm - fc1.fm * fc2.fz
        elif sign == '*':
            fz = fc1.fz * fc2.fz
        elif sign == "/":
            fz = fc1.fz * fc2.fz
        else:
            print("暂不支持")
            return 0
        if sign =="/":
            fm = fc1.fm*fc2.fz
        else:
            fm = fc1.fm*fc2.fz
        fm = fc1.fm*fc2.fm

    # 创建新分数对象
        fs = Faction(fz,fm)
        return fs.chang_format()

fc1 = Faction(1,2)
fc2 = Faction(3,4)
mf = ManageFaction()
result = mf.adjust(fc1, fc2,'*')
print(result)